<!DOCTYPE html>
<html>
<head>
    <title>WebSocket - Simple Client</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"></script>
    <script src="js/socket.io.js"></script>
    <script type="text/javascript">

	$(function() {
		// bind form
		$('#payload-form').submit(function() {
			var payload = ($("input#payload").val());
			//socket.send(payload);  // write to server
			socket.emit("my other event", {my: "bla bla bla"});
			return false;
		});

		var socket = io.connect('http://localhost:8080');
		
		socket.on('connect', function() {
                    alert("connected");
                });
			
		socket.on('news', function (data) {
		    console.log(data);
		    socket.emit('my other event', { my: 'data' });
		});
	});	
    </script>
</head>
<body>
	<div id='payload-container'>
		<form id='payload-form'>
			<input type='text' name='payload' id='payload' value='Hello World' style="width:500px;"/>
			<input type='submit' value='push'/>
		</form>
	</div>

	<div id='log' style='display:block; border:1px solid lightgray;'></div>
</body>
</html>